$(function(){
    var loginName=baseFunction.getUrlParameterValueByKey("loginName");
    $(".btn").on("click",function(){
        var oldPassword=$("#oldPassword").val();
        var newPassword1=$("#newPassword1").val();
        var newPassword2=$("#newPassword2").val();
        if (newPassword1 != newPassword2){ //判断两次密码是否一致
            $(".prompt").html("密码输入不一致").show(0).delay(1000).hide(0);
            return;
        }
        // 提高用户体验
        $(".prompt").html("提交中...").show(0).delay(1000).hide(0);
        var data={
            userName: baseFunction.encryption(loginName),
            type: "1", //1修改密码 2找回密码
            oldPassword: baseFunction.encryption(hexMD5(oldPassword)) , //先用md5加密  然后再一次加密
            newPassword: baseFunction.encryption(hexMD5(newPassword1)),
        };
        baseFunction.netRequest("modPwd",data,function(res){
            
            $(".prompt").html(res.message).show(0).delay(1000).hide(0);
            if (res.code==200){ //修改成功
                setTimeout(function(){
                    window.location.href="my_passwordManage.html?loginName="+loginName+"";
                },1000)
            }
        })
    })
})